<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-08-27 17:04:35
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: BOM成品工艺
 */

namespace App\Models;

use App\Traits\MaterialTrait;

class ProPotRawDetail extends BaseModel
{
    use MaterialTrait;
    protected $casts = [
        'rate'         => 'double',
        'quantity'     => 'double',
        'new_quantity' => 'double',
        'new_rate'     => 'double',
    ];
    public $timestamps = true;

    public $table = "sys_pro_pot_raw_detail";
    protected $guarded = [];

    public function pro_pot()
    {
        return $this->belongsTo(ProPlan::class);
    }
    public function uunit()
    {
        return $this->belongsTo(Dic::class, "uunit_id", "key")->where(function ($q) {
            $q->where("code", 'AuxiliaryUUnit');
        });
    }
    public function ounit()
    {
        return $this->belongsTo(Dic::class, "ounit_id", "key")->where(function ($q) {
            $q->where("code", 'AuxiliaryOUnit');
        });
    }
}
